﻿<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="tabOrderDetail.ascx.cs" Inherits="CustomerService.OrderDetailTab" %>
<script type="text/javascript" language="javascript">
    function btnAdd_onclick() {
        var orderID = document.getElementById('<%=txtOrderID.ClientID %>').value;
        TearOff("AddDetailItem.aspx?OrderID=" + orderID + "&PanelID=<%= OrderDetailPanel.UniqueID %>", "AddDetailItem", "600", "400");
    }

    function btnCancel_onclick() {
        var orderID = document.getElementById('<%=txtOrderID.ClientID %>').value;
        TearOff("CancelOrder.aspx?OrderID=" + orderID + "&PanelID=<%= OrderDetailPanel.UniqueID %>", "AddDetailItem", "600", "400");
    }
</script>
<asp:TextBox style="display:none;" ID="txtOrderID" runat="server" />
<table cellpadding="0" cellspacing="0" class="OrderDetail">
    <tr>
        <td>
            <div class="orderform">
                <table cellspacing="0" cellpadding="0" border="0" class="CustomerEntry" onload="address_onload();">
                    <tr>
                        <td class="half">
                            <b>Order Number:</b><br />
                            <%= _orderHeader.OrderID.ToString() %>
                        </td>
                        <td class="half">
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <b>Order Date:</b><br />
                            <%=  _orderHeader.OrderDate.ToShortDateString()%>
                        </td>
                        <td class="half">
                            <b>Sch Ship Date:</b><br />
                            <asp:TextBox ID="txtProjShipDate" runat="server" />
                            <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtProjShipDate" />
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <b>Order Status:</b><br />
                            <%= (_orderHeader.OrderStatus==null)?string.Empty:_orderHeader.OrderStatus.Name %>
                        </td>
                        <td class="half">
                            <b>Hold Reason:</b><br />
                            <%= (_orderHeader.HoldReason==null)?string.Empty:_orderHeader.HoldReason.Name %>
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <b>Order Type:</b><br />
                            <%= (_orderHeader.OrderType==null)?string.Empty:_orderHeader.OrderType.Description %>
                        </td>
                        <td class="half">
                            <b>Order Source:</b><br />
                            <%= (_orderHeader.OrderSource==null)?string.Empty:_orderHeader.OrderSource.Description %>
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                        </td>
                        <td class="half">
                            <b>Shipping:</b><br />
                            <asp:TextBox ID="txtShipping" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                        </td>
                        <td class="half">
                            <b>Taxes:</b><br />
                            <%= _orderHeader.Taxes.ToString("C") %>
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                        </td>
                        <td class="half">
                            <b>Total:</b><br />
                            <%= _orderHeader.OrderTotal.ToString("C") %>
                        </td>
                    </tr>
                </table>
            </div>
        </td>
        <td>
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <asp:UpdatePanel ID="OrderDetailPanel" runat="server">
                        <ContentTemplate>
                        <asp:ListView ID="ListView1" runat="server" DataKeyNames="OrderDetailID">
                            <LayoutTemplate>
                                <table cellpadding="3" cellspacing="0" class="ItemList">
                                    <tr>
                                        <td>
                                            Qty
                                        </td>
                                        <td>
                                            Code
                                        </td>
                                        <td>
                                            Name
                                        </td>
                                        <td>
                                            Price
                                        </td>
                                        <td>
                                            Discount
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr id="itemPlaceholder" runat="server"></tr>
                                </table>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <tr>
                                    <td>
                                        <asp:TextBox ID="txtItemQty" runat="server" Text='<%# Bind("Qty")%>' Width="40" 
                                            Enabled=<%# Eval("OrderHeader.CanEdit")%> />
                                    </td>
                                    <td>
                                        <%# Eval("Product.ItemCode") %>                                        
                                    </td>
                                    <td>
                                        <%# Eval("Product.ShortName") %>                                        
                                    </td>
                                    <td>
                                        <%# Eval("UnitPrice") %>                                        
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtDiscount" runat="server" Text='<%# Bind("Discount")%>' Width="60" 
                                            Enabled=<%# Eval("OrderHeader.CanEdit") %> />
                                    </td>
                                    <td style="display:<%# ((bool)Eval("OrderHeader.CanEdit")) ? "block" : "none" %>">
                                        <asp:Button ID="btnRemove" runat="server" Text="Del" Width="40" 
                                         CommandName="Delete" CommandArgument='<%# Eval("OrderDetailID") %>'
                                         OnCommand="btnRemove_Click"
                                        />
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:ListView>
                        </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input id="btnAddItem" type="button" value="Add Item..." runat="server" onclick="btnAdd_onclick();" />&nbsp&nbsp
                        <input ID="btnCancelOrder" type="button" runat="server" value="Cancel Order..." onclick="btnCancel_onclick();" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
